package org.mybatis3.demo1;

import org.apache.ibatis.session.SqlSession;
import org.mybatis3.demo1.dao.RoleMapper;
import org.mybatis3.demo1.dao.UserMapper;
import org.mybatis3.demo1.pojo.Address;
import org.mybatis3.demo1.pojo.Role;
import org.mybatis3.demo1.pojo.User;
import org.mybatis3.util.MyBatisUtil;

import java.util.List;

public class Test10 {
    public static void main(String[] args) {
        //11222
        SqlSession sqlSession = MyBatisUtil.getSqlSession();

        List<User> userList = sqlSession.getMapper(UserMapper.class).getUsersAndAddress();
        for (int i = 0; i < userList.size(); i++) {

            System.out.println("用户：" + userList.get(i).getUserCode() );
            List<Address> addresses=userList.get(i).getAddresses();
            for (int j=0;j<addresses.size();j++){
                System.out.println("     地址："+addresses.get(j).getAddressDesc());
            }
        }
        MyBatisUtil.closeSqlSession();
    }
}
